<ul id="myTab" class="nav nav-tabs">
        <li class="active"><a href="">On Going Project</a></li>
		<li class=""><a href="<?php echo site_url('user/tasks/completed_projects')?>" >Completed Projects</a></li>              
</ul>   
<h3>On-Going Projects <a href="<?= site_url('user/tasks/projects')?>"><small class="text-info"><i class="icon-plus"></i> Add New Project</small></a> </h3>
<div class="row-fluid">
<div class="pull-right"> <b>Filter : </b>
<?php foreach($departments as $department) {?>
<span class="label"><?php echo $department->name?></span>
<?php }?>
</div>
</div>
<br />
<?php if($this->session->flashdata('msg')) {?>
<div id="alert" class="alert alert-success">
<i class="icon-ok-circle"></i>  <?= $this->session->flashdata('msg') ?>
</div>
<?php }?>
<?php foreach($departments as $depart) {?>
<h3 class="widget-name"><?php echo ucfirst($depart->name)?></h3>
<div id="contentLeft">
<ul type="none" class="project">
<?php
$projects = $this->task_model->get_project_by_department($depart->id);
if(count($projects)){
foreach($projects as $project) {?>
<li id="recordsArray_<?= $project->id?>">
<div class="row-fluid">
<div class="span3">
<a  href="<?= site_url('user/tasks/milestones_details').'/'.$project->id?>"><?= ucfirst($project->name);?></a>
</div>
<div class="span2">
<span >
<?php
if($project->client_id != 0){
echo $this->common_model->get_username_id($project->client_id);	
}
?>	
</span>
</div>
<div class="span2"><a class="tooltips" title="Assigned to"><?= ucfirst($this->common_model->get_username_id($project->assigned_to));?></a></div>
<div class="span1"><?php echo round($this->task_model->get_percentage_by_projectid($project->id)).' %';?></div>
<div class="span2 muted" ><?= "Due - ".$project->end_date?></div>
<div class="span2">
<div class="btn-group">
  <button class="btn"><i class="icon-cog"></i></button>
  <button class="btn dropdown-toggle" data-toggle="dropdown">
    <span class="caret"></span>
  </button>
  <ul class="dropdown-menu">
    <!-- dropdown menu links -->	
	<li><a href="<?php echo site_url('user/tasks/edit_project').'/'.$project->id?>"><i class="icon-edit"></i> Edit</a></li>
	<li><a onclick="completed(<?php echo $project->id?>)" style="cursor: pointer;"><i class="icon-ok"></i> Closed</a></li>	
  </ul>
</div>

	<?php 
	// get fav
	$fav = $this->task_model->get_fav_project($project->id,$this->session->userdata('user_id'));	
	if(count($fav)==0){
	?>
	<a href="javascript:void(0)"  id="fav" onclick="add_fav_project(<?php echo $project->id;?>)"><i class="icon-star-empty" id="star"></i> </a>
	<?php }else{?>	
	<a href="javascript:void(0)"  id="nofav" onclick="remove_fav_project(<?php echo $project->id;?>)" ><i class="icon-star" id="star"></i> </a>
	<?php }?>
	
</div>
</div>
</li>
<?php } } else { echo 'No Project Assigned'; }?>
</ul>
</div>
<?php }?>
<hr />

<script type="text/javascript">
	$(document).ready(function(e)
		{
			// drag n drop
			//alert("asdds");
			jQuery(function()
				{

					jQuery("#contentLeft ul").sortable(
						{
							opacity: 0.6, cursor: 'move',  update: function()
							{
								var order = jQuery(this).sortable("serialize") + '&action=updateRecordsListings';
									alert(order);
								jQuery.post("<?= site_url('user/tasks/sorting_projects');?>", order, function(theResponse)
									{
										alert(theResponse);
									});
							}
						});
						
				});
		})

function completed(project_id)
{
//alert('asd');
//alert(project_id)
$.post('<?= site_url('user/tasks/project_completed');?>',{project_id : project_id }, function(data) {		
				alert('Project Completed Successfully');
				location.reload();
});	
}
	
function incompleted(project_id)
{
//alert('asd');
//alert(project_id)
$.post('<?= site_url('user/tasks/project_incompleted');?>',{project_id : project_id }, function(data) {		
				alert('Project Opened');
				location.reload();
});	
}	


function add_fav_project(pId) {		
		$.post('<?= site_url("user/tasks/add_fav_project");?>',{id:pId}, function(data) {						
			//$('#fav').hide();
			//$('#nofav').show();
			location.reload();
	});
	}
	function remove_fav_project(pId) {	
		$.post('<?= site_url("user/tasks/remove_fav_project");?>',{id:pId}, function(data) {			
			//$('#fav').show();
			//$('#nofav').hide();
			location.reload();
	});
	}
	
	function follow_project(pId) {	
		$.post('<?= site_url("user/tasks/follow_project");?>',{id:pId}, function(data) {
			
			location.reload();
	});
	}
	
</script>

